package com.ruoyi.web.controller.mall.shopExpressMoney.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.mall.shopExpressMoney.domain.ShopExpressMoney;
import com.ruoyi.web.controller.mall.shopExpressMoney.service.IShopExpressMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * semController
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@Controller
@RequestMapping("/mall/shopExpressMoney")
public class ShopExpressMoneyController extends BaseController
{
    private String prefix = "mall/shopExpressMoney";

    @Autowired
    private IShopExpressMoneyService shopExpressMoneyService;

//    @RequiresPermissions("mall:shopExpressMoney:view")
    @GetMapping()
    public String shopExpressMoney()
    {
        return prefix + "/shopExpressMoney";
    }

    /**
     * 查询sem列表
     */
//    @RequiresPermissions("mall:shopExpressMoney:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ShopExpressMoney shopExpressMoney)
    {
        startPage();
        List<ShopExpressMoney> list = shopExpressMoneyService.selectShopExpressMoneyList(shopExpressMoney);
        return getDataTable(list);
    }

    /**
     * 导出sem列表
     */
//    @RequiresPermissions("mall:shopExpressMoney:export")
    @Log(title = "sem", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ShopExpressMoney shopExpressMoney)
    {
        List<ShopExpressMoney> list = shopExpressMoneyService.selectShopExpressMoneyList(shopExpressMoney);
        ExcelUtil<ShopExpressMoney> util = new ExcelUtil<ShopExpressMoney>(ShopExpressMoney.class);
        return util.exportExcel(list, "shopExpressMoney");
    }

    /**
     * 新增sem
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存sem
     */
//    @RequiresPermissions("mall:shopExpressMoney:add")
    @Log(title = "sem", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ShopExpressMoney shopExpressMoney)
    {
        return toAjax(shopExpressMoneyService.insertShopExpressMoney(shopExpressMoney));
    }

    /**
     * 修改sem
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ShopExpressMoney shopExpressMoney = shopExpressMoneyService.selectShopExpressMoneyById(id);
        mmap.put("shopExpressMoney", shopExpressMoney);
        return prefix + "/edit";
    }

    /**
     * 修改保存sem
     */
//    @RequiresPermissions("mall:shopExpressMoney:edit")
    @Log(title = "sem", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ShopExpressMoney shopExpressMoney)
    {
        return toAjax(shopExpressMoneyService.updateShopExpressMoney(shopExpressMoney));
    }

    /**
     * 删除sem
     */
//    @RequiresPermissions("mall:shopExpressMoney:remove")
    @Log(title = "sem", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String[] ids)
    {
        return toAjax(shopExpressMoneyService.deleteShopExpressMoneyByIds(ids));
    }
}
